package com.study.mybatis.session;

import com.study.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author yuantongqin
 * 2021/7/31
 **/
public class SqlSessionFactoryBuilder {

    public static SqlSessionFactory builder(String resource){
        InputStream resourceAsStream = SqlSessionFactoryBuilder.class.getClassLoader().getResourceAsStream(resource);
        Configuration configuration = new Configuration();
        try {
            configuration.getConfig().load(resourceAsStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new DefaultSqlSessionFactory(configuration);
    }
}
